package com.ruoyi.tcsp.utils;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.tcsp.domain.bean.req.ScientificInfoReq;
import com.ruoyi.tcsp.domain.bean.req.TcspExpertInfoReq;
import com.ruoyi.tcsp.domain.mysql.ScientificBaseInfo;
import com.ruoyi.tcsp.domain.mysql.TcspExpertInfo;
import org.apache.tomcat.util.bcel.Const;

import java.util.Date;
public class ConvertUtils {

    public static ScientificBaseInfo convert(ScientificInfoReq req) {
        ScientificBaseInfo baseInfo = new ScientificBaseInfo();
        baseInfo.setScientificName(req.getScientificName());
        baseInfo.setApplicantName(req.getApplicantName());
        baseInfo.setAgentName(req.getAgentName());
        baseInfo.setApplicationDate(new Date());
        baseInfo.setEvaluateLeval(Constants.THE_NEW_SIC_EVAL_LEV);
        baseInfo.setInventorName(req.getInventorName());
        //为该科技成果设置 专利号
        Long time = new Date().getTime();
        String string = time.toString();
        baseInfo.setPatentNo("TCSP-"+string.substring(0,12));
        //设置初始公开号
        baseInfo.setPublicNumber(Constants.THE_NEW_SIC_PUBLIC_NUM);
        baseInfo.setIpcType(req.getIpcType());
        //初始状态设置为  在审
        baseInfo.setStatus(Constants.THE_NEW_SIC_STATUS);
        return baseInfo;
    }

    public static TcspExpertInfo convert(TcspExpertInfoReq req, LoginUser loginUser) {
        TcspExpertInfo tcspExpertInfo = new TcspExpertInfo();
        tcspExpertInfo.setExpertAvatar(req.getExpertAvatar());
        tcspExpertInfo.setJob(req.getJob());
        tcspExpertInfo.setExpertName(req.getExpertName());
        tcspExpertInfo.setEmail(req.getEmail());
        tcspExpertInfo.setCollege(req.getCollege());
        tcspExpertInfo.setCreateTime(DateUtils.getNowDate());
        tcspExpertInfo.setCreateBy(loginUser.getUsername());
        tcspExpertInfo.setPersonInfo(req.getPersonInfo());
        return tcspExpertInfo;
    }


}
